﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.DirectX.Direct3D;

namespace BurningSphere.Simulator
{
	public class Lasers
	{
		List<Laser> lasers = new List<Laser>();

		public Lasers()
		{
		}

		public void Load(string xmlFile)
		{
			XmlDocument xml = new XmlDocument();
			xml.Load(xmlFile);

			foreach (XmlElement element in xml.DocumentElement)
			{
				Laser laser = new Laser();
				laser.LoadFromXmlElement(element);
				lasers.Add(laser);
			}
		}

		public void OnLostDevice()
		{
			foreach (Laser laser in lasers)
			{
				laser.OnLostDevice();
			}
		}

		public void Initialise(Device device)
		{
			foreach (Laser laser in lasers)
			{
				laser.Initialise(device);
			}
		}

		public void Shutdown()
		{
			foreach (Laser laser in lasers)
			{
				laser.Shutdown();
			}
			lasers.Clear();
		}

		public void Update()
		{
			foreach (Laser laser in lasers)
			{
				laser.Update();
			}
		}

		public void Render(Device device)
		{
			foreach (Laser laser in lasers)
			{
				laser.Render(device);
			}
		}
	}
}
